package file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description：正确处理关闭文件的操作
 * User：chenshu
 * Date：2023-11-15
 * Time：22:43
 */
public class Demo4 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("test.txt")) {
            Scanner scanner = new Scanner(inputStream);
            System.out.println(scanner.next());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
